#!/usr/bin/python
# -*- coding: UTF-8 -*-

from kpautos.engine.case import Case
from kptest.config.enum import DeviceType, HostType, DeviceUtility


class openUBMC_IPMI_OS_Sensor_001(Case):
    """
        Name:
            openUBMC_IPMI_OS_Sensor_001
        Label:
            验证IPMI接口支持带内获取Sensor list
        PreCondition:
            1、BMC正常运行
            2、OS正常运行
        TestStep:
            1、使用ipmitool sensor list获取Sensor list，有结果A）
        ExpectedResult:
            A）正常获取到Sensor list，包含传感器名称，读值，状态，且传感器与实际一致,时间不超过30s；
        Parameters:

        Remark:

    """

    # 测试执行前配置等准备操作
    def pre_test_case(self):
        self.device_dut = self.resource.get_device(device_type=DeviceType.Server, utility=DeviceUtility.DUT)
        self.os_host = self.device_dut.get_host(host_type=HostType.HostOS)
        # self.ipmi_api = self.device_dut.get_api(ns_name="Ipmi")

    # 测试步骤
    def procedure(self):
        self.log_step("1、IPMI带内获取Sensor list，有结果A）")
        ipmi_os_sensor_result = self.os_host.send_combination_keys('ipmitool sensor list', timeout=30)
        self.assertTrue(ipmi_os_sensor_result, "带内获取Sensor list成功")
        self.logger.info("A）正常获取到Sensor list；")

    # 测试结束后恢复环境
    def post_test_case(self):
        pass
